﻿using UnityEngine;
using System.Collections;
using System.Diagnostics;
using System.Collections.Generic;
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Net
{
    public partial class AsycUdpClient
    {
        /// <summary>
        /// 类似心跳线程
        /// </summary>
        void AliveThread()
        {
            while (Connected)
            {
                try
                {
                    tcpSocket.GetStream().Write(new byte[] { 1 }, 0, 1);
                }
                catch (Exception e)
                {
                    CatchException(e);
                }

                //1s发送一次
                Thread.Sleep(1000);
            }

            Disconnect();
        }
    }
}

